package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysAPlotList;
import com.ruoyi.system.service.ISysAPlotListService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小区信息列表Controller
 * 
 * @author ruoyi
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/system/plot")
public class SysAPlotListController extends BaseController
{
    private String prefix = "system/plot";

    @Autowired
    private ISysAPlotListService sysAPlotListService;

    @RequiresPermissions("system:plot:view")
    @GetMapping()
    public String plot()
    {
        return prefix + "/plot";
    }

    /**
     * 查询小区信息列表列表
     */
    @RequiresPermissions("system:plot:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysAPlotList sysAPlotList)
    {
        startPage();
        List<SysAPlotList> list = sysAPlotListService.selectSysAPlotListList(sysAPlotList);
        return getDataTable(list);
    }

    /**
     * 导出小区信息列表列表
     */
    @RequiresPermissions("system:plot:export")
    @Log(title = "小区信息列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysAPlotList sysAPlotList)
    {
        List<SysAPlotList> list = sysAPlotListService.selectSysAPlotListList(sysAPlotList);
        ExcelUtil<SysAPlotList> util = new ExcelUtil<SysAPlotList>(SysAPlotList.class);
        return util.exportExcel(list, "小区信息列表数据");
    }

    /**
     * 新增小区信息列表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存小区信息列表
     */
    @RequiresPermissions("system:plot:add")
    @Log(title = "小区信息列表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysAPlotList sysAPlotList)
    {
        return toAjax(sysAPlotListService.insertSysAPlotList(sysAPlotList));
    }

    /**
     * 修改小区信息列表
     */
    @GetMapping("/edit/{plotId}")
    public String edit(@PathVariable("plotId") String plotId, ModelMap mmap)
    {
        SysAPlotList sysAPlotList = sysAPlotListService.selectSysAPlotListByPlotId(plotId);
        mmap.put("sysAPlotList", sysAPlotList);
        return prefix + "/edit";
    }

    /**
     * 修改保存小区信息列表
     */
    @RequiresPermissions("system:plot:edit")
    @Log(title = "小区信息列表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysAPlotList sysAPlotList)
    {
        return toAjax(sysAPlotListService.updateSysAPlotList(sysAPlotList));
    }

    /**
     * 删除小区信息列表
     */
    @RequiresPermissions("system:plot:remove")
    @Log(title = "小区信息列表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysAPlotListService.deleteSysAPlotListByPlotIds(ids));
    }
}
